package java8;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @auther hanchao
 * @date 2017/3/7 11:28
 */
public class LambdaTest {
    public static void main(String[] args){
        ExecutorService executor = Executors.newFixedThreadPool(1);
        executor.execute(() -> System.out.println("lambda"));
        //方法引用
        executor.execute(LambdaTest::testRef);
        executor.shutdown();

        List list = new ArrayList();
        list.add(3);
        list.add(1);
        list.add(2);
        list.forEach(n -> {
                System.out.println("数字"+n);
        });


        System.out.println("------------------");
        //冲突的时候需要这么强转
        testConflict((A) () -> System.out.println("ccc"));
    }

    public static void  test(Fly fly){
        fly.fly();
    }

    public static void testRef(){
        System.out.println("method ref");
    }

    public static void testLong(int s){
        System.out.println(s);
    }

    public static void testConflict(A a){
        System.out.println("aaaa");
    }

    public static void testConflict(B b){
        System.out.println("bbbb");
    }

}

interface A{
    public void testa();
}
interface B{
    public void testb();
}